﻿
Imports std

Public Module ranker
    Public Function rankcategory(ByVal cats As [set](Of String), ByRef rtn As vector(Of String)) As Boolean
        If rtn Is Nothing Then
            rtn = New vector(Of String)
        Else
            rtn.clear()
        End If

        Dim it As [set](Of String).iterator = Nothing
        it = cats.begin()
        While it <> cats.end()
            rtn.push_back(+it)
            it += 1
        End While

        Return True
    End Function

    Public Function rankfeed(ByVal feeds As [set](Of String), ByRef rtn As vector(Of String)) As Boolean
        If rtn Is Nothing Then
            rtn = New vector(Of String)
        Else
            rtn.clear()
        End If

        Dim it As [set](Of String).iterator = Nothing
        it = feeds.begin()
        While it <> feeds.end()
            rtn.push_back(+it)
            it += 1
        End While

        Return True
    End Function

    Public Function rankcategoryfeed(ByVal feeds As [set](Of String), ByVal category As String _
                                     , ByRef rtn As vector(Of pair(Of String, Double))) As Boolean
        If rtn Is Nothing Then
            rtn = New vector(Of pair(Of String, Double))
        Else
            rtn.clear()
        End If

        Dim it As [set](Of String).iterator = Nothing
        it = feeds.begin()
        While it <> feeds.end()
            rtn.push_back(make_pair(+it, 1.0 / feeds.size()))
            it += 1
        End While

        Return True
    End Function
End Module
